import Mock from 'mockjs'
import { builder } from "../util"
import type { version } from 'nprogress'

const info = (options:any) => {
    const userInfo = {
      id: '4291d7da9005377ec9aec4a71ea837f',
      name: '天野远子',
      username: 'admin',
      password: '',
      avatar: '/avatar2.jpg',
      status: 1,
      telephone: '',
      lastLoginIp: '27.154.74.117',
      lastLoginTime: 1534837621348,
      creatorId: 'admin',
      createTime: 1497160610259,
      merchantCode: 'TLif2btpzg079h15bk',
      deleted: 0,
      roleId: 'admin',
      roles: {}
    }

    return builder(userInfo, 'success', 200)
  }

  const devices = (options:any) => {
    const devices = {
      total: 100,
      pageNum: 1,
      pageSize: 10,
      list: [
        {
          id: '1',
          name: '设备1',
          carType: 'type1',
          vin: '1231231',
          status: 'used',
          ip: '192.168.1.1',
          mac: '00:11:22:33:44:55',
          osVersion: '1.0.0',
          connectionStatus: 'online',
          creator: 'admin',
          creatorId: 1,
          lastOnlineTime: 1629123456789,
          lastOnlineIp: '192.168.1.1',
          clientType: 'wanhuatong',
          clientVersion: '1.0.0',
          os: 'Windows 10',
        }, 
        {
          id: '2',
          name: '设备2',
          vin: '123123211',
          carType: 'type2',
          status: 'unused',
          ip: '192.168.1.2',
          mac: '00:11:22:33:44:56',
          osVersion: '2.0.0',
          connectionStatus: 'offline',
          creator: 'admin',
          creatorId: 1,
          lastOnlineTime: 1629123456789,
          lastOnlineIp: '192.168.1.2',
          clientType: 'app',
          version: '3.0.0',
          os: 'Android 10',
        }
      ]
    }
    return builder(devices, 'success', 200)
}

const CarTypeList = (options:any) => {
    const CarTypeList = {
      total: 10,
      pageNum: 1,
      pageSize: 10,
      list: [
        {
          id: '1',
          name: '车型1',
          status: 1,
          createTime: 1629123456789,
          creatorId: 'admin',
        }
      ]
    }
    return builder(CarTypeList, 'success', 200)
}

Mock.mock(/\/api\/v1\/device\/ListDevicesPage/, 'post', devices)
Mock.mock(/\/api\/v1\/device\/ListCarTypePage/, 'post', CarTypeList)
